package com.haisen.core.shiro.spring;

import com.alibaba.fastjson.JSON;
import com.haisen.dataobject.vo.DingH5TokenVO;
import org.apache.shiro.cache.Cache;
import org.apache.shiro.cache.CacheManager;

import java.util.concurrent.atomic.AtomicInteger;

public class DingH5TokenManager {

    private Cache<String, String> cacheToken;

    public DingH5TokenManager(CacheManager cacheManager) {
        this.cacheToken = cacheManager.getCache("dingh5wximpTokenCache");
    }

    public void createToken(DingH5TokenVO dingH5TokenVO){
        cacheToken.put("dingH5WximpToken", JSON.toJSONString(dingH5TokenVO));
    }

    public void deleteToken(String key){
         cacheToken.remove(key);
    }

    public String loadToken(String key){
        return cacheToken.get(key);
    }

}
